package com.ssy.invoicing.dao.support;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.SqlMapClientCallback;

import com.ssy.invoicing.dao.support.BaseSqlDao.SplitPageResult;

/**
 * @author suoyao.shen
 */
@SuppressWarnings("rawtypes")
public interface IBaseSqlData {
    
    void delete(String statementName, Object parameterObject, int requiredRowsAffected)
            throws DataAccessException;

    int delete(String statementName, Object parameterObject) throws DataAccessException;

    int delete(String statementName) throws DataAccessException;

    Object execute(SqlMapClientCallback arg0) throws DataAccessException;

    List<?> executeWithListResult(SqlMapClientCallback action) throws DataAccessException;

    Map<?,?> executeWithMapResult(SqlMapClientCallback action) throws DataAccessException;

    Object insert(String statementName, Object parameterObject) throws DataAccessException;
    
    Object insert(String statementName) throws DataAccessException;

    List<?> queryForList(String statementName, int skipResults, int maxResults)
            throws DataAccessException;

    List<?> queryForList(String statementName, Object parameterObject, int skipResults,
                             int maxResults) throws DataAccessException ;

    List<?> queryForList(String statementName, Object parameterObject)
            throws DataAccessException;

    List<?> queryForList(String statementName) throws DataAccessException;

    Map<?,?> queryForMap(String statementName, Object parameterObject, String keyProperty,
                           String valueProperty) throws DataAccessException;

    Map<?,?> queryForMap(String statementName, Object parameterObject, String keyProperty)
            throws DataAccessException ;

    Object queryForObject(String statementName, Object parameterObject, Object resultObject)
            throws DataAccessException;

    Object queryForObject(String statementName, Object parameterObject)
            throws DataAccessException ;

    Object queryForObject(String statementName) throws DataAccessException ;

    void update(String statementName, Object parameterObject, int requiredRowsAffected)
            throws DataAccessException;

    int update(String statementName, Object parameterObject) throws DataAccessException ;
   
    int update(String statementName) throws DataAccessException ;

    /**
     * 分页查询
     * @param statementName 查询语句，在SQLMap配置文件中，<b>参数类型需要设置为java.util.HashMap</b>。因为需要利用Map传递分页的参数
     * @param countStatementName 统计总数的语句，参数类型可以不变
     * @param parameterObject 包含查询参数的对象，如果此对象不是Map的实例，则会新建一个map来包装此参数，key为：paramObj
     * @param pageNo 需要查询的页码
     * @return
     */
    SplitPageResult queryListByPagination(String statementName, String countStatementName,
                                                 Object parameterObject, int pageNo)
            throws SQLException ;
}
